package com.zjs.express.common;

public class ResultModel<T> {

    private boolean success;
    private String message;
    private T rows;
    private Integer total;

    public ResultModel() {
        // 默认构造函数
    }

    public ResultModel(boolean success, String message, T rows) {
        this.success = success;
        this.message = message;
        this.rows = rows;
    }

    public ResultModel(boolean success, String message, T rows, Integer total) {
        this.success = success;
        this.message = message;
        this.rows = rows;
        this.total = total;
    }

    public static <T> ResultModel<T> success() {
        return new ResultModel<>(true, "操作成功", null);
    }

    public static <T> ResultModel<T> success(T rows) {
        return new ResultModel<>(true, "操作成功", rows);
    }

    public static <T> ResultModel<T> success(T rows, Integer total) {
        return new ResultModel<>(true, "操作成功", rows, total);
    }

    public static <T> ResultModel<T> failure(String message) {
        return new ResultModel<>(false, message, null);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getRows() {
        return rows;
    }

    public void setRows(T rows) {
        this.rows = rows;
    }
}
